
package edu.upc.clase.demo.service.impl;

import edu.upc.clase.demo.dao.LocalDao;
import edu.upc.clase.demo.dao.impl.LocalDaoImpl;
import edu.upc.clase.demo.entity.Local;
import edu.upc.clase.demo.service.LocalService;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

public class LocalServiceImpl implements LocalService{
    
    private static Logger log = LoggerFactory.getLogger(LocalDaoImpl.class);    
    
    @Autowired
    private LocalDao localDao;
   
    @Override
    public Integer insertar(Local local) {
        if (local.getCodLocal().length() > 4) {
            log.info("Creando local");
            return localDao.insertar(local);
        }       
        return null;
    }

    @Override
    public void actualizar(Local local) {
        log.info("Actualizando Local");
        localDao.actualizar(local);
    }

    @Override
    public void eliminar(Local local) {
        log.info("Eliminando local");
        localDao.eliminar(local);
    }

    @Override
    public List<Local> buscarTodos() {
        log.info("Buscando todos los locales");
        return localDao.buscarTodos();
    }

    @Override
     public Local buscar(String codLocal) {
        log.info("Buscar local por codLocal");
        return localDao.buscar(codLocal);
    }
}

